<template>
  <div class="scroll-wrapper" ref="wrapper">
      <div class="scroll-content"></div>
  </div>
</template>

<script>
import BetterScroll from 'better-scroll';

import { DetailModel } from 'models/detail';

import tools from 'utils/tools'
export default {
  name: 'DetailScrollWrapper',
  data () {
      return {
          field: '',
          id: 0
      }
  },
  created () {
      this.field = this.$route.query.field
      this.id = this.$route.query.id
      this.getDetail(this.field, this.id)
  },
  mounted () {
    this.scroll = new BetterScroll(this.$refs.wrapper)
  },
  methods: {
      getDetail (field, id) {
          const detailModel = new DetailModel();
          detailModel.getDetail(field, id).then((res) => {
              if (res && res.status === 0) {
                  const data = res.data
                  data.pics && (data.pics = tools.jsonToArr(data.pics))
                  data.comment_keyword && (data.comment_keyword = tools.strToArr(data.comment_keyword))
                  data.recom && (data.recom = tools.replaceToSpace(data.recom))
                  data.service && (data.service = tools.jsonToArr(data.service))
              }
          })
      }
  }
}
</script>

<style lang="scss" scoped>

</style>